﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using JM.JCY.Proxy;
using System.IO;
using System.Globalization;
using System.Text.RegularExpressions;
using Microsoft.SharePoint;
using NCS.IConnect.ApplicationContexts;
using JM.JCY.BusinessEntity;

namespace JM.JCY.SharePointComponent.Committee.CommitteeHome
{
    public partial class CommitteeHomeUserControl : UserControl
    {
        public int _userId
        {
            set { ViewState["_userId"] = value; }
            get { return (int)ViewState["_userId"]; }
        }

        public int _committeeId
        {
            set { ViewState["_committeeId"] = value; }
            get { return (int)ViewState["_committeeId"]; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (ApplicationContext.Current.GetKeyValue("userId") != null)
            {
                _userId = Int32.Parse(ApplicationContext.Current.GetKeyValue("userId").ToString());
            }

            if (!IsPostBack)
            {
                if (Request.QueryString["CommitteeId"] != null)
                {
                    _committeeId = Int32.Parse(Request.QueryString["CommitteeId"].ToString());
                    this.hfCommitteeId.Value = _committeeId.ToString();
                    using (UserManagementProxy proxy = new UserManagementProxy())
                    {
                        var dt = proxy.GetCommitteeById(_committeeId);
                        if (dt.Rows.Count > 0)
                        {
                            this.lblCommitteeName.Text = dt[0].CommitteeName;
                            this.lblCommitteeDesc.Text = dt[0].CommitteeDescription;
                        
                            if (_userId != dt[0].Creator)
                            {
                                this.imgEdit.Visible = false;
                                this.lkbEditCommittee.Visible = false;
                            }
                        }

                    }

                }
               }

        }

        protected void lkbEditCommittee_Click(object sender, EventArgs e)
        {
            string url = @"CommitteePages/EditCommitteeMember.aspx?CommitteeId=";
            Response.Redirect(url + _committeeId.ToString());
        }

      


    


    }
}
